package com.symaster.backups.enumerate;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
public enum BackupFolderPathType {
    APPLICATION_ROOT("APPLICATION_ROOT", "程序目录"),
    CUSTOM_PATH("CUSTOM_PATH", "自定义目录"),
    ;

    private final String key;
    private final String label;
    public static final BackupFolderPathType defaultEnum = BackupFolderPathType.APPLICATION_ROOT;

    private static final Map<String, BackupFolderPathType> byKey;

    static {
        byKey = Arrays.stream(BackupFolderPathType.values()).collect(Collectors.toMap(BackupFolderPathType::getKey, e -> e));
    }

    BackupFolderPathType(String key, String label) {
        this.key = key;
        this.label = label;
    }

    public static BackupFolderPathType ofKey(String key) {
        return byKey.get(key);
    }

    @Override
    public String toString() {
        return label;
    }
}